// 定义路由表

import Home from "../views/Home.vue";
import Hello from "../views/Hello.vue";
import {createRouter,createWebHashHistory} from "vue-router";
import User from "../views/user/User.vue";
import UserProfile from "../views/user/UserProfile.vue";
import UserPosts from "../views/user/UserPosts.vue";

const routes = [
    { path: '/',component: Home },
    { path: '/hello',component: Hello },
    { path: '/haha/:id',component: ()=> import('../views/Haha.vue'), },
    {
        path: '/user/:id',
        component: User,
        children: [
            {
                path: 'profile',
                component: UserProfile,
            },

            {
                path: 'posts',
                component: UserPosts,
            },
        ]
    }
]
// 创建路由器
const router = createRouter({
    history: createWebHashHistory(),
    routes,

});

// 导出路由器
export default router;

// vue 实例使用路由器



